package com.tieshu.matissecrop.utils;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.zhihu.matisse.engine.ImageEngine;

/**
 * 自定义Glide加载引擎，用于知乎图片选择器
 */
public class MyGlideEngine implements ImageEngine {
    @Override
    public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {


        Glide.with(context).load(uri).placeholder(placeholder).override(resize,resize).centerCrop().into(imageView);
    }

    @Override
    public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {

        Glide.with(context).load(uri).placeholder(placeholder).override(resize,resize).centerCrop().into(imageView);
    }

    @Override
    public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {

        Glide.with(context).load(uri).override(resizeX,resizeX).centerCrop().into(imageView);

    }


    @Override
    public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
        Glide.with(context).load(uri).override(resizeX,resizeX).centerCrop().into(imageView);

    }

    @Override
    public boolean supportAnimatedGif() {
        return true;
    }
}
